package mysql

import "gorm.io/gorm"

type Good struct {
	gorm.Model
	GoodsName  string  `gorm:"type:varchar(20);comment:商品名称"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);comment:商品价格"`
	GoodsStock int     `gorm:"type:int(20);comment:商品库存"`
	GoodsImg   string  `gorm:"type:varchar(255);comment:商品封面"`
}

func (g *Good) GoodsCreate() error {
	return DB.Create(&g).Error
}

func (g *Good) GoodsInfo(GoodsId int64) error {
	return DB.Where("id=?", GoodsId).Limit(1).Find(&g).Error
}
